import React from 'react';
import { format } from '@/utils/datetime';
import CommonPage from '@/components/page/CommonPage';
import { renderNumber } from '@/utils/common';
import { useModel } from 'umi';
const daoName = 'ShBxzsdr';
const importName = 'ShBxzsdr';

const columns: API.Column[] = [
  {
    title: '序号',
    width: 120,
    sorter: true,
    dataIndex: 'XH',
    key: 'XH',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '申请日期',
    width: 120,
    sorter: true,
    key: 'SQSJ',
    dataIndex: 'SQSJ',
    render: (data) => format(data, 'yyyy-MM-dd'),
    dispaly: true,
    filter: false,
    export: false,
  },
  {
    title: '保单号',
    width: 120,
    sorter: true,
    dataIndex: 'BDH',
    key: 'BDH',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '险种名称',
    width: 250,
    sorter: true,
    dataIndex: 'XZMC',
    key: 'XZMC',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '投保人名称',
    width: 120,
    sorter: true,
    dataIndex: 'TBRXM',
    key: 'TBRXM',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '缴费年期',
    width: 120,
    sorter: true,
    dataIndex: 'JFNQ',
    key: 'JFNQ',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '保费',
    width: 150,
    sorter: true,
    dataIndex: 'BF',
    key: 'BF',
    dispaly: true,
    filter: true,
    export: true,
    align: 'right',
    render: (data) => renderNumber('.2f', data),
  },
  {
    title: '手续费率',
    width: 150,
    sorter: true,
    dataIndex: 'SXFLL',
    key: 'SXFLL',
    dispaly: true,
    filter: true,
    export: true,
    align: 'right',
    render: (data) => renderNumber('.2f', data),
  },
  {
    title: '手续费金额(税后)',
    width: 150,
    sorter: true,
    dataIndex: 'SXFJE',
    key: 'SXFJE',
    dispaly: true,
    filter: false,
    export: true,
    align: 'right',
    render: (data) => renderNumber('.2f', data),
  },
  {
    title: '销售人工号',
    width: 150,
    sorter: true,
    dataIndex: 'XSRYGH',
    key: 'XSRYGH',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '销售人姓名',
    width: 120,
    sorter: true,
    dataIndex: 'XSRYXM',
    key: 'XSRYXM',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '导入日期',
    width: 120,
    sorter: true,
    key: 'DRRQ',
    dataIndex: 'DRRQ',
    render: (data) => format(data, 'yyyy-MM-dd'),
    dispaly: true,
    filter: false,
    export: false,
  },

  {
    title: '操作人',
    width: 120,
    sorter: true,
    dataIndex: 'CZR',
    key: 'CZR',
    dispaly: true,
    filter: false,
    export: false,
  },
  {
    title: '操作人ID',
    width: 120,
    sorter: true,
    dataIndex: 'CZRID',
    key: 'CZRID',
    dispaly: true,
    filter: false,
    export: false,
  },
  {
    title: '操作日期',
    width: 120,
    sorter: true,
    key: 'CZRQ',
    dataIndex: 'CZRQ',
    render: (data) => format(data, 'yyyy-MM-dd'),
    dispaly: true,
    filter: false,
    export: false,
  },
];
const controls: API.Control[] = [
  {
    name: 'XH',
    rules: [{ required: true, message: '不能为空' }],
    type: 'text',
    label: '序号',
    grid: 12 / 24,
  },
  {
    name: 'SQSJ',
    rules: [{ required: true, message: '不能为空' }],
    dataType: 'date',
    type: 'date',
    label: '申请时间',
    grid: 12 / 24,
  },
  {
    name: 'BDH',
    rules: [{ required: true, message: '不能为空' }],
    type: 'text',
    label: '保单号',
    grid: 12 / 24,
  },
  {
    name: 'XZMC',
    rules: [{ required: true, message: '不能为空' }],
    type: 'text',
    label: '险种名称',
    grid: 12 / 24,
  },
  {
    name: 'TBRXM',
    rules: [{ required: true, message: '不能为空' }],
    type: 'text',
    label: '投保人姓名',
    grid: 12 / 24,
  },
  {
    name: 'JFNQ',
    rules: [{ required: true, message: '不能为空' }],
    type: 'text',
    label: '缴费年期',
    grid: 12 / 24,
  },
  {
    name: 'BF',
    rules: [{ required: true, message: '不能为空' }],
    type: 'number',
    dataType: 'number',
    label: '保费',
    grid: 12 / 24,
  },
  {
    name: 'SXFLL',
    rules: [{ required: true, message: '不能为空' }],
    type: 'number',
    dataType: 'number',
    label: '手续费率',
    grid: 12 / 24,
  },
  {
    name: 'SXFJE',
    rules: [{ required: true, message: '不能为空' }],
    type: 'number',
    dataType: 'number',
    label: '手续费金额(税后)',
    grid: 12 / 24,
  },
  {
    name: 'XSRYGH',
    rules: [{ required: true, message: '不能为空' }],
    type: 'text',
    label: '销售人员工号',
    grid: 12 / 24,
  },
  {
    name: 'XSRYXM',
    rules: [{ required: true, message: '不能为空' }],
    type: 'text',
    label: '销售人员姓名',
    grid: 12 / 24,
  },
  { name: 'DRRQ', dataType: 'date', type: 'date', label: '导入日期', grid: 12 / 24 },
];

const ShIndiPhjrForm: React.FC = () => {
  const { user } = useModel('@@initialState', (ret) => {
    return {
      user: ret.initialState?.user,
    };
  });
  return (
    <CommonPage
      daoName={daoName}
      columns={columns}
      controls={controls}
      title="保险中收导入"
      keyColName={'EMID'}
      importName={importName}
      importControls={controls}
      importMode="DeleteAfterInsert"
      importParamNames={['DRRQ']}
      importParamVals={{ CZRID: '' + user?.userID, CZR: user?.name }}
      importTemplateName="保险中收导入模板"
      initSorter={{ FieldName: 'XH', Direction: 'ASC' }}
    />
  );
};

export default ShIndiPhjrForm;
